home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2001 May
/
SGI Freeware 2001 May - Disc 3.iso
/
dist
/
fw_openssl.idb
/
usr
/
freeware
/
catman
/
p_man
/
cat3
/
BN_add.Z
/
BN_add
Wrap
Text File
|
2001-01-10
|
5KB
|
133 lines
BBBBNNNN____aaaadddddddd((((3333)))) 22224444////FFFFeeeebbbb////2222000000000000 ((((0000....9999....6666)))) BBBBNNNN____aaaadddddddd((((3333))))
NNNNAAAAMMMMEEEE
BN_add, BN_sub, BN_mul, BN_div, BN_sqr, BN_mod, BN_mod_mul,
BN_exp, BN_mod_exp, BN_gcd - arithmetic operations on
BIGNUMs
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
#include <openssl/bn.h>
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
BN_CTX *ctx);
int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
BN_CTX *ctx);
int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx);
int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
_B_N__a_d_d() adds aaaa and bbbb and places the result in rrrr (r=a+b). rrrr
may be the same BBBBIIIIGGGGNNNNUUUUMMMM as aaaa or bbbb.
_B_N__s_u_b() subtracts bbbb from aaaa and places the result in rrrr
(r=a-b).
_B_N__m_u_l() multiplies aaaa and bbbb and places the result in rrrr
(r=a*b). rrrr may be the same BBBBIIIIGGGGNNNNUUUUMMMM as aaaa or bbbb. For
multiplication by powers of 2, use BN_lshift(3).
_B_N__d_i_v() divides aaaa by dddd and places the result in ddddvvvv and the
remainder in rrrreeeemmmm (dv=a/d, rem=a%d). Either of ddddvvvv and rrrreeeemmmm may
be NULL, in which case the respective value is not returned.
For division by powers of 2, use _B_N__r_s_h_i_f_t(3).
_B_N__s_q_r() takes the square of aaaa and places the result in rrrr
(r=a^2). rrrr and aaaa may be the same BBBBIIIIGGGGNNNNUUUUMMMM. This function is
faster than _B_N__m_u_l(r,a,a).
Page 1 (printed 11/10/00)
BBBBNNNN____aaaadddddddd((((3333)))) 22224444////FFFFeeeebbbb////2222000000000000 ((((0000....9999....6666)))) BBBBNNNN____aaaadddddddd((((3333))))
_B_N__m_o_d() find the remainder of aaaa divided by mmmm and places it
in rrrreeeemmmm (rem=a%m).
_B_N__m_o_d__m_u_l() multiplies aaaa by bbbb and finds the remainder when
divided by mmmm (r=(a*b)%m). rrrr may be the same BBBBIIIIGGGGNNNNUUUUMMMM as aaaa or
bbbb. For a more efficient algorithm, see
BN_mod_mul_montgomery(3); for repeated computations using
the same modulus, see BN_mod_mul_reciprocal(3).
_B_N__e_x_p() raises aaaa to the pppp-th power and places the result in
rrrr (r=a^p). This function is faster than repeated
applications of _B_N__m_u_l().
_B_N__m_o_d__e_x_p() computes aaaa to the pppp-th power modulo mmmm (r=a^p %
m). This function uses less time and space than _B_N__e_x_p().
_B_N__g_c_d() computes the greatest common divisor of aaaa and bbbb and
places the result in rrrr. rrrr may be the same BBBBIIIIGGGGNNNNUUUUMMMM as aaaa or bbbb.
For all functions, ccccttttxxxx is a previously allocated BBBBNNNN____CCCCTTTTXXXX used
for temporary variables; see BN_CTX_new(3).
Unless noted otherwise, the result BBBBIIIIGGGGNNNNUUUUMMMM must be different
from the arguments.
RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEESSSS
For all functions, 1 is returned for success, 0 on error.
The return value should always be checked (e.g., if
(!BN_add(r,a,b)) goto err;). The error codes can be
obtained by ERR_get_error(3).
SSSSEEEEEEEE AAAALLLLSSSSOOOO
bn(3), err(3), BN_CTX_new(3), BN_add_word(3), BN_set_bit(3)
HHHHIIIISSSSTTTTOOOORRRRYYYY
_B_N__a_d_d(), _B_N__s_u_b(), _B_N__d_i_v(), _B_N__s_q_r(), _B_N__m_o_d(),
_B_N__m_o_d__m_u_l(), _B_N__m_o_d__e_x_p() and _B_N__g_c_d() are available in all
versions of SSLeay and OpenSSL. The ccccttttxxxx argument to _B_N__m_u_l()
was added in SSLeay 0.9.1b. _B_N__e_x_p() appeared in SSLeay
0.9.0.
BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs"
Page 2 (printed 11/10/00)